package com.city.repository.party;

import com.city.domain.party.PartyFabroad;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @deprecation: 干部出国申请
 * @dmail: 398521613@qq.com
 * @author: L-H
 * @date: 2018-07-18 13:14
 */
public interface PartyFabroadRepository extends JpaRepository<PartyFabroad,Integer> {

    //分页查询
    @Query(value = "select * from party_fabroad limit ?1,?2",nativeQuery = true)
    List<PartyFabroad> findAllByPage(Integer page, Integer limit);

    //模糊查询  根据目的地
    @Query(value = "select * from party_fabroad  where destination like %?1%  limit ?2,?3",nativeQuery = true)
    List<PartyFabroad> findAllByDestinationAndPage(String destination, Integer page, Integer limit);

    //根据  目的地统计总数
    @Query(value = "SELECT count(*) from party_fabroad where destination like %?1%",nativeQuery = true)
    long countDestination(String destination);

    //模糊查询  根据目的地
    @Query(value = "select * from party_fabroad  where name like %?1%  limit ?2,?3",nativeQuery = true)
    List<PartyFabroad> findAllByNameAndPage(String name, Integer page, Integer limit);

    //根据  目的地统计总数
    @Query(value = "SELECT count(*) from party_fabroad where name like %?1%",nativeQuery = true)
    long countName(String name);

    //模糊查询  根据目的地和名字
    @Query(value = "select * from party_fabroad  where destination like %?1% and name like %?2%  limit ?3,?4",nativeQuery = true)
    List<PartyFabroad> findAllByDestinationAndNameAndPage(String destination,String name, Integer page, Integer limit);

    //根据  目的地统计总数
    @Query(value = "SELECT count(*) from party_fabroad where destination like %?1% and name like %?2%",nativeQuery = true)
    long countDestinationAndName(String destination,String name);





}
